<!DOCTYPE html>

<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">

<title>class UsersController - Rails Application Documentation</title>

<link type="text/css" media="screen" href="./rdoc.css" rel="stylesheet">

<script type="text/javascript">
  var rdoc_rel_prefix = "./";
</script>

<script type="text/javascript" charset="utf-8" src="./js/jquery.js"></script>
<script type="text/javascript" charset="utf-8" src="./js/navigation.js"></script>
<script type="text/javascript" charset="utf-8" src="./js/search_index.js"></script>
<script type="text/javascript" charset="utf-8" src="./js/search.js"></script>
<script type="text/javascript" charset="utf-8" src="./js/searcher.js"></script>
<script type="text/javascript" charset="utf-8" src="./js/darkfish.js"></script>


<body id="top" class="class">
<nav id="metadata">
  <nav id="home-section" class="section">
  <h3 class="section-header">
    <a href="./index.html">Home</a>
    <a href="./table_of_contents.html#classes">Classes</a>
    <a href="./table_of_contents.html#methods">Methods</a>
  </h3>
</nav>


  <nav id="search-section" class="section project-section" class="initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <h3 class="section-header">
      <input type="text" name="search" placeholder="Search" id="search-field"
             title="Type to search, Up and Down to navigate, Enter to load">
    </h3>
  </form>

  <ul id="search-results" class="initially-hidden"></ul>
</nav>


  <div id="file-metadata">
    <nav id="file-list-section" class="section">
  <h3 class="section-header">Defined In</h3>
  <ul>
    <li>app/controllers/users_controller.rb
  </ul>
</nav>

    
  </div>

  <div id="class-metadata">
    
    <nav id="parent-class-section" class="section">
  <h3 class="section-header">Parent</h3>
  
  <p class="link"><a href="ApplicationController.html">ApplicationController</a>
  
</nav>

    
    <!-- Method Quickref -->
<nav id="method-list-section" class="section">
  <h3 class="section-header">Methods</h3>

  <ul class="link-list">
    
    <li><a href="#method-i-login">#login</a>
    
    <li><a href="#method-i-logout">#logout</a>
    
  </ul>
</nav>

  </div>

  <div id="project-metadata">
    <nav id="fileindex-section" class="section project-section">
  <h3 class="section-header">Pages</h3>

  <ul>
  
    <li class="file"><a href="./doc/README_FOR_APP.html">README_FOR_APP</a>
  
  </ul>
</nav>

    <nav id="classindex-section" class="section project-section">
  <h3 class="section-header">Class and Module Index</h3>

  <ul class="link-list">
  
    <li><a href="./ApplicationController.html">ApplicationController</a>
  
    <li><a href="./ApplicationHelper.html">ApplicationHelper</a>
  
    <li><a href="./CountiesController.html">CountiesController</a>
  
    <li><a href="./County.html">County</a>
  
    <li><a href="./GreaterArea.html">GreaterArea</a>
  
    <li><a href="./GreaterAreasController.html">GreaterAreasController</a>
  
    <li><a href="./Language.html">Language</a>
  
    <li><a href="./LanguageMajoritiesController.html">LanguageMajoritiesController</a>
  
    <li><a href="./LanguageMajority.html">LanguageMajority</a>
  
    <li><a href="./LanguageOfficialitiesController.html">LanguageOfficialitiesController</a>
  
    <li><a href="./LanguageOfficiality.html">LanguageOfficiality</a>
  
    <li><a href="./LanguagesController.html">LanguagesController</a>
  
    <li><a href="./Location.html">Location</a>
  
    <li><a href="./LocationType.html">LocationType</a>
  
    <li><a href="./LocationTypeGroup.html">LocationTypeGroup</a>
  
    <li><a href="./LocationTypeGroupsController.html">LocationTypeGroupsController</a>
  
    <li><a href="./LocationTypeSubgroup.html">LocationTypeSubgroup</a>
  
    <li><a href="./LocationTypeSubgroupsController.html">LocationTypeSubgroupsController</a>
  
    <li><a href="./LocationTypesController.html">LocationTypesController</a>
  
    <li><a href="./LocationsController.html">LocationsController</a>
  
    <li><a href="./Map.html">Map</a>
  
    <li><a href="./MapController.html">MapController</a>
  
    <li><a href="./MapHelper.html">MapHelper</a>
  
    <li><a href="./MunicipalitiesController.html">MunicipalitiesController</a>
  
    <li><a href="./Municipality.html">Municipality</a>
  
    <li><a href="./Province.html">Province</a>
  
    <li><a href="./ProvincesController.html">ProvincesController</a>
  
    <li><a href="./Region.html">Region</a>
  
    <li><a href="./RegionsController.html">RegionsController</a>
  
    <li><a href="./ScaleRelevanciesController.html">ScaleRelevanciesController</a>
  
    <li><a href="./ScaleRelevancy.html">ScaleRelevancy</a>
  
    <li><a href="./User.html">User</a>
  
    <li><a href="./UsersController.html">UsersController</a>
  
    <li><a href="./UsersHelper.html">UsersHelper</a>
  
  </ul>
</nav>

  </div>
</nav>

<div id="documentation">
  <h1 class="class">class UsersController</h1>

  <div id="description" class="description">
    
  </div><!-- description -->

  
  
  
  <section id="5Buntitled-5D" class="documentation-section">
    

    

    

    

    <!-- Methods -->
    
     <section id="public-instance-5Buntitled-5D-method-details" class="method-section section">
      <h3 class="section-header">Public Instance Methods</h3>

    
      <div id="method-i-login" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">login</span><span
            class="method-args">()</span>
          <span class="method-click-advice">click to toggle source</span>
        </div>
        

        <div class="method-description">
          
          <p>users_controller method for handling logins.</p>

<p>POST data <a href="http://:username">params</a> and <a
href="http://:password">params</a> are passed to the <a
href="User.html">User</a> model method that handles the authentication.</p>

<p>Upon successful authentication we store the credentials to <a
href="http://:user">session</a> hash and redirect to root_path.</p>
          

          
          <div class="method-source-code" id="login-source">
            <pre><span class="ruby-comment"># File app/controllers/users_controller.rb, line 11</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">login</span>
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">request</span>.<span class="ruby-identifier">post?</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">session</span>[<span class="ruby-value">:user</span>] = <span class="ruby-constant">User</span>.<span class="ruby-identifier">authenticate</span>(<span class="ruby-identifier">params</span>[<span class="ruby-value">:username</span>], <span class="ruby-identifier">params</span>[<span class="ruby-value">:password</span>])
      <span class="ruby-identifier">session</span>[<span class="ruby-value">:user</span>][<span class="ruby-value">:username</span>] = <span class="ruby-identifier">params</span>[<span class="ruby-value">:username</span>]
      <span class="ruby-identifier">session</span>[<span class="ruby-value">:user</span>][<span class="ruby-value">:password</span>] = <span class="ruby-identifier">params</span>[<span class="ruby-value">:password</span>]
      <span class="ruby-comment"># flash[:notice] = 'Kirjautuminen onnistui'</span>
      <span class="ruby-identifier">redirect_to</span> <span class="ruby-identifier">root_path</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">flash</span>[<span class="ruby-value">:notice</span>] = <span class="ruby-string">'Kirjautuminen ei onnistunut'</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">session</span>[<span class="ruby-value">:user</span>] <span class="ruby-operator">!=</span> <span class="ruby-keyword">nil</span>
    <span class="ruby-identifier">flash</span>[<span class="ruby-value">:notice</span>] = <span class="ruby-string">'Kirjaudu ensin ulos'</span>
    <span class="ruby-identifier">redirect_to</span> <span class="ruby-identifier">root_path</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
          </div><!-- login-source -->
          
        </div>

        

        
      </div><!-- login-method -->

    
      <div id="method-i-logout" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">logout</span><span
            class="method-args">()</span>
          <span class="method-click-advice">click to toggle source</span>
        </div>
        

        <div class="method-description">
          
          <p>users_controller method for handling logouts.</p>

<p><a href="http://:user">session</a> hash is cleared and user redirected to
the login page.</p>
          

          
          <div class="method-source-code" id="logout-source">
            <pre><span class="ruby-comment"># File app/controllers/users_controller.rb, line 32</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">logout</span>
  <span class="ruby-identifier">session</span>[<span class="ruby-value">:user</span>] = <span class="ruby-keyword">nil</span>
  <span class="ruby-identifier">flash</span>[<span class="ruby-value">:notice</span>] = <span class="ruby-string">'Kirjauduit ulos'</span>
  <span class="ruby-identifier">redirect_to</span> <span class="ruby-value">:action</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">'login'</span>
<span class="ruby-keyword">end</span></pre>
          </div><!-- logout-source -->
          
        </div>

        

        
      </div><!-- logout-method -->

    
    </section><!-- public-instance-method-details -->
  
  </section><!-- 5Buntitled-5D -->

</div><!-- documentation -->


<footer id="validator-badges">
  <p><a href="http://validator.w3.org/check/referer">[Validate]</a>
  <p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a> 3.12.
  <p>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish Rdoc Generator</a> 3.
</footer>

